package com.mysqlpass.update.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.logging.Logger;

/**
 * 下载页面控制器，提供MySQLPass的下载页面
 */
@Controller
public class DownloadPageController {
    
    private static final Logger logger = Logger.getLogger(DownloadPageController.class.getName());
    
    @Value("${update.file.current-version}")
    private String currentVersion;
    
    @Value("${update.file.latest-version}")
    private String latestVersion;
    
    @Value("${update.file.file-name}")
    private String fileName;
    
    /**
     * 显示下载页面
     * @param model 模型对象，用于传递数据到视图
     * @return 视图名称
     */
    @GetMapping("/")
    public String showDownloadPage(Model model) {
        logger.info("显示MySQLPass下载页面");
        
        // 添加页面需要的数据
        model.addAttribute("appName", "MySQLPass");
        model.addAttribute("currentVersion", currentVersion);
        model.addAttribute("latestVersion", latestVersion);
        model.addAttribute("fileName", fileName);
        model.addAttribute("isLatestVersion", currentVersion.equals(latestVersion));
        
        // 返回视图名称
        return "download";
    }
}